<?php
include_once "common/basic.php";
if($_POST["r"]){
	//检查验证码
	if(!$func->vcode_check($_POST[vcode])){
		$func->error("e12060901","非法注册！");
	}
	
	$mail = strtolower(trim($_POST[mail]));
	$name = trim($_POST[name]);
	$pwd = trim($_POST[pwd]);
	$website = trim($_POST[website]);
	$mydesc = trim($_POST[mydesc]);
	
	$res = $func->register_validate_field($mail, $name, $pwd, $website, $mydesc);
	
	$e_mail = $res[e_email];
	$e_name = $res[e_name];
	$e_pwd = $res[e_pwd];
	$e_website = $res[e_website];
	$e_mydesc = $res[e_mydesc];
	
	//创建新用户
	if(!$e_mail && !$e_name && !$e_name && !$e_pwd && !$e_pwd2 && !$e_website && !$e_mydesc){
		$uid = $func->createUser($mail, $name, $pwd,$website,$mydesc);
		if($uid){
			$user = $func->getUserById($uid);
			$func->register_welcomemail($user,$config[smtp],$config[weburl],$config[webname]);
			$func->makeSession($user);
			
			if($_GET[refer] && strpos(strtolower($_GET[refer]), "register.php")===false){
				$func->redirect($_GET[refer]);
			}else{
				$func->redirect("my.php");
			}			
			
			die();
		}else{
			$func->error("e12062701","创建用户失败");
		}
	}
}
$tl->set_file("register");
$tl->p();
?>